package neca.tmazo.vista.vistaGUI;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JTextPane;

import neca.tmazo.datasets.Music;
import neca.tmazo.modelo.WindowEventListener;
import neca.tmazo.vista.WindowItems;

/**
 * 
 * @author neca
 *
 */
public class VentanaMiBiblioteca extends JPanel {

	/**
	 * Crea el panel para la ventana de la cancion.
	 * @param observer 
	 */
	private ListaMusica listaMusica=null;
	public VentanaMiBiblioteca(final WindowEventListener observer, final Music[] myMusic) {
		setSize(new Dimension(750, 500));
		setBounds(new Rectangle(0, 0, 750, 500));
		setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBackground(Color.DARK_GRAY);
		panel.setForeground(Color.DARK_GRAY);
		panel.setBounds(0, 0, 750, 100);
		add(panel);
		panel.setLayout(null);
		
		JButton btnAtras = new JButton("Atras");
		btnAtras.setBackground(Color.DARK_GRAY);
		btnAtras.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				observer.onMenuItemSelected(WindowItems.MIBIBLIOTECA_BOTON_ATRAS, null);
			}
		});
		btnAtras.setBounds(620, 30, 120, 40);
		panel.add(btnAtras);
		
		JTextPane txtpnMiRecopilatorio = new JTextPane();
		txtpnMiRecopilatorio.setForeground(Color.LIGHT_GRAY);
		txtpnMiRecopilatorio.setEditable(false);
		txtpnMiRecopilatorio.setBackground(Color.DARK_GRAY);
		txtpnMiRecopilatorio.setFont(new Font("Dialog", Font.BOLD, 30));
		txtpnMiRecopilatorio.setText("Mi Biblioteca");
		txtpnMiRecopilatorio.setBounds(10, 10, 308, 45);
		panel.add(txtpnMiRecopilatorio);
		
		final JComboBox comboBox = new JComboBox();
		comboBox.setBackground(Color.WHITE);
		comboBox.setModel(new DefaultComboBoxModel(new String[] {"Todo", "Canciones", "Albumes"}));
		comboBox.setSelectedIndex(0);
		comboBox.setBounds(70, 65, 90, 20);
		comboBox.addActionListener (new ActionListener () {
		    public void actionPerformed(ActionEvent e) {
		        switch(comboBox.getSelectedIndex())
		        {
		        case 0:
		        	listaMusica.deleteFilters();
		        	break;
		        case 1:
		        	listaMusica.filterBySong();
		        	break;
		        case 2:
		        	listaMusica.filterByAlbum();
		        	break;
		        }
		    }
		});
		panel.add(comboBox);
		
		JTextPane txtpnMostrarTus = new JTextPane();
		txtpnMostrarTus.setForeground(Color.LIGHT_GRAY);
		txtpnMostrarTus.setFont(new Font("Tahoma", Font.PLAIN, 12));
		txtpnMostrarTus.setBackground(Color.DARK_GRAY);
		txtpnMostrarTus.setText("Mostrar");
		txtpnMostrarTus.setBounds(10, 65, 50, 20);
		panel.add(txtpnMostrarTus);
		
		this.listaMusica = new ListaMusica(myMusic,observer,WindowItems.MIBIBLIOTECA_BOTON_MUSICA,WindowItems.MIBIBLIOTECA_FORMULARIO_INDICEMUSICASELECCIONADA);
		this.listaMusica.setBounds(0, 100, 750, 400);
		add(this.listaMusica);
		
		
		
		
	}
}
